package com.qfedu.zf.life.mapper;

import com.qfedu.zf.common.param.CommentCreatDTO;
import com.qfedu.zf.common.param.CommentDTO;
import com.qfedu.zf.life.entity.Comment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author wjw
 * @since 2024-06-20
 */
public interface CommentMapper extends BaseMapper<Comment> {

    @Select("SELECT c.id, c.content, c.create_time, u.nickname, u.avatar " +
            "FROM comment c " +
            "LEFT JOIN user u ON c.user_id = u.id")
    List<CommentDTO> selectCommentDTOList(Long postPageId);
    //添加评论
    @Insert("INSERT INTO comment (user_id, post_page_id, content, create_time) VALUES (#{userId}, #{postPageId}, #{content}, NOW())")
    void insertComment(CommentCreatDTO commentCreatDTO);
}
